﻿using System;
using System.Windows.Forms;
using System.IO;

namespace BookManage
{
    public partial class Welcome : Form
    {
        private class Driver
        {
            System.IO.DriveInfo info;

            public System.IO.DriveInfo Info
            {
                get { return info; }
                set { info = value; }
            }
            string text;
            public Driver(System.IO.DriveInfo info)
            {
                this.info = info;
                text = info.VolumeLabel + " ("+info.Name + ")";
            }
            public override string  ToString()
            {
                return text;
            }
        }
        public Welcome()
        {
            InitializeComponent();
            System.IO.DriveInfo[] disk = System.IO.DriveInfo.GetDrives();
            foreach (System.IO.DriveInfo temp in disk)
            {
                if (temp.DriveType.GetHashCode()==2)
                {
                    this.Drive.Items.Add(new Driver(temp));                    
                }
            }
        }

        private void OK_Click(object sender, EventArgs e)
        {
            DirectoryInfo dir = new DirectoryInfo(((Driver)Drive.SelectedItem).Info.Name + "DK_Documents\\");
            if (dir.Exists)
            {
                this.DialogResult = DialogResult.OK;
            }
            else
                MessageBox.Show("未发现多看文件夹，请选择Kindle盘符", "Error！");
        }
    }
}
